﻿<!--<Window x:Class="TestVisioCanvas.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:visio="clr-namespace:AxMicrosoft.Office.Interop.VisOcx;assembly=AxInterop.Microsoft.Office.Interop.VisOcx"
        xmlns:System="clr-namespace:System;assembly=mscorlib"
        xmlns:models="clr-namespace:TestVisioCanvas.Models"
        xmlns:converters="clr-namespace:TestVisioCanvas.Converters"
        Title="MainWindow" WindowState="Maximized" MouseUp="_WFHost_MouseUp" MinHeight="600" MinWidth="960"
        Icon="psm_logo_violet.png" TouchUp="Window_TouchUp" WindowStyle="None">
  <Window.Resources>
    <converters:EnumNameConverter x:Key="CategoryNameConverter"/>    
    <ControlTemplate TargetType="{x:Type Button}" x:Key="ActionButton">
      <Border Margin="0,2,0,0" Name="BTBorder"  BorderThickness="1" BorderBrush="DarkGray" Background="#FF4800AE">
        <TextBlock Margin="2,2,2,2" HorizontalAlignment="Center" VerticalAlignment="Center"
            Text="{Binding RelativeSource={RelativeSource AncestorType=Button, Mode=FindAncestor}, Path=Content}"
            FontFamily="Segoe UI" FontWeight="SemiBold" FontSize="13" Foreground="White"/>
      </Border>
      <ControlTemplate.Triggers>
        <Trigger Property="IsPressed" Value="True">
          <Setter TargetName="BTBorder" Property="BorderThickness" Value="3"/>
          <Setter TargetName="BTBorder" Property="BorderBrush" Value="Yellow"/>
        </Trigger>
        <Trigger Property="IsPressed" Value="false">
          <Setter TargetName="BTBorder" Property="BorderThickness" Value="1"/>
          <Setter TargetName="BTBorder" Property="BorderBrush" Value="Black"/>
        </Trigger>
      </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="CategoryLBItem" TargetType="ListBoxItem">
      <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type ListBoxItem}" >
            <Border Margin="0,2,0,0" Name="BTBorder"  BorderThickness="0" BorderBrush="DarkGray"
                Background="#FF4800AE" >
              <ContentPresenter/>
            </Border>           
            <ControlTemplate.Triggers>
              <Trigger Property="IsSelected" Value="True">
                <Setter TargetName="BTBorder" Property="Background" Value="Magenta"/>
              </Trigger>
              <Trigger Property="IsSelected" Value="false">
                <Setter TargetName="BTBorder" Property="Background" Value="#FF4800AE"/>
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

    <ObjectDataProvider x:Key="CategoryEnumDataProvider"
            MethodName="GetValues" ObjectType="{x:Type System:Enum}">
      <ObjectDataProvider.MethodParameters>
        <x:Type TypeName="models:MasterCategory"/>
      </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>

  </Window.Resources>
  <Grid Name="LayoutRoot" MouseUp="_WFHost_MouseUp" TouchUp="Window_TouchUp" Margin="20,16,0,-10">
    <Grid.RowDefinitions>
      <RowDefinition Height=".12*"/>
      <RowDefinition Height=".77*"/>
      <RowDefinition Height=".11*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width=".12*"/>
      <ColumnDefinition Width=".675*"/>
      <ColumnDefinition Width=".20*"/>
      <ColumnDefinition Width=".02*"/>
    </Grid.ColumnDefinitions>
    --><!-- Grid Intestazione --><!--
    <Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Top" HorizontalAlignment="Stretch"
        Margin="8, 8, 0, 20" Visibility="Collapsed">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="0.05*"/>
        <ColumnDefinition Width="0.45*"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <TextBlock Grid.Column="0" VerticalAlignment="Center"
          Text="Cliente : " FontFamily="Segoe UI" FontWeight="SemiBold" FontSize="20"/>
      <TextBox Name="NameTBox" Height="40" HorizontalContentAlignment="Stretch"
          Grid.Column="2" HorizontalAlignment="Stretch" TextChanged="NameTBox_TextChanged"
          Width="{Binding RelativeSource={RelativeSource AncestorType=ColumnDefinition, Mode=FindAncestor}, Path=ActualWidth}"
          BorderBrush="#FF4800AE" BorderThickness="0,0,0,2" VerticalContentAlignment="Center" VerticalAlignment="Center"
          FontFamily="Segoe UI" FontWeight="SemiBold" FontSize="20"/>
    </Grid>

    <Image Grid.Column="2" Grid.Row="0" Source="/Images/LogoCreative.jpg" Margin="0,4,4,6" VerticalAlignment="Top"/>
    <Rectangle Grid.ColumnSpan="3" Height="4" Fill="Gray" Grid.Row="0" VerticalAlignment="Bottom"
        Margin="0,4,0,16"/>
    <Border Grid.Column="1" Width="20" Height="20" Background="Magenta" CornerRadius="3"
        Margin="0,4,100,8" VerticalAlignment="Bottom" BorderThickness="0" HorizontalAlignment="Right"/>

    <Frame x:Name="_frame" Grid.Row="1" Grid.Column="1" NavigationUIVisibility="Hidden"/>
    --><!--Host for VisioDrawingControls --><!--
    <WindowsFormsHost Grid.Row="1" Grid.Column="1" Name="_WFHost"
        AllowDrop="True" Margin="20,0,20,-10">
      <visio:AxDrawingControl x:Name="_drawingControl"
          ShapeAdded="_drawingControl_ShapeAdded"
          QueryCancelPageDelete="_drawingControl_QueryCancelPageDelete"
          PageAdded="_drawingControl_PageAdded" PageChanged="_drawingControl_PageChanged"
          MouseUpEvent="_drawingControl_MouseUpEvent"
          BeforeSelectionDelete="_drawingControl_BeforeSelectionDelete"/>
    </WindowsFormsHost>

    <Grid Grid.Column="0" Grid.Row="1" Margin="0,0,0,-10">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="0.75*"/>
      </Grid.RowDefinitions>
      --><!--Categories Listbox--><!--
      <ListBox Grid.Row="0"
          ItemContainerStyle="{StaticResource CategoryLBItem}"
          ItemsSource="{Binding Source={StaticResource ResourceKey=CategoryEnumDataProvider}}"
          ScrollViewer.HorizontalScrollBarVisibility="Disabled"
          SelectionChanged="ListBox_SelectionChanged">
        <ListBox.ItemTemplate>
          <DataTemplate>
            <TextBlock Margin="4,0,0,0" FontFamily="Segoe UI" FontWeight="SemiBold" FontSize="13" Foreground="White"
            Text="{Binding Converter={StaticResource ResourceKey=CategoryNameConverter}}" />
          </DataTemplate>
        </ListBox.ItemTemplate>
      </ListBox>
      --><!--Masters Listbox--><!--
      <ListBox x:Name="_MasterLB" Grid.Row="1"
           ScrollViewer.ScrollChanged="_MasterLB_ScrollChanged"
           ScrollViewer.HorizontalScrollBarVisibility="Disabled"
           ScrollViewer.VerticalScrollBarVisibility="Hidden" VerticalContentAlignment="Top"
           PreviewMouseLeftButtonDown="_MasterLB_PreviewMouseLeftButtonDown"
           PreviewTouchDown="_MasterLB_PreviewTouchDown"
           ItemsSource="{Binding MastersQuery}">
        <ListBox.ItemsPanel>
          <ItemsPanelTemplate>
            <UniformGrid Columns="2" VerticalAlignment="Top"/>
          </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.ItemTemplate>
          <DataTemplate>
            <StackPanel Margin="2" MaxHeight="96" >
              <Image Source="{Binding Image}" MaxHeight="52" HorizontalAlignment="Center"
                  VerticalAlignment="Center"/>
              <TextBlock Margin="1" HorizontalAlignment="Center"
                  Text="{Binding DisplayName}" FontFamily="Segoe UI" FontSize="11"
                  TextWrapping="Wrap"/>
            </StackPanel>
          </DataTemplate>
        </ListBox.ItemTemplate>
      </ListBox>
    </Grid>
    --><!--Scrolling buttons--><!--
    <Grid Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Visibility="Visible"
        Margin="0,0,0,0">      
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0.4*"/>
        <ColumnDefinition Width="0.2*"/>
        <ColumnDefinition Width="0.4*"/>
      </Grid.ColumnDefinitions>
      <Rectangle Height="2" Fill="Gray" Grid.ColumnSpan="3" VerticalAlignment="Center"
          Margin="0,0,4,0"/>
      <Button Grid.Column="2" Name="ScrollDownButton"
          Click="ScrollDownButton_Click" TouchUp="ScrollDownButton_TouchUp"
          VerticalAlignment="Bottom"
          Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0">
        <Image Source="/Images/Icons/Arrow_d.png" Stretch="Uniform"/>
      </Button>
      <Button Grid.Column="0"  Name="ScrollUpButton" VerticalAlignment="Top"
          Click="ScrollUpButton_Click" TouchUp="ScrollUpButton_TouchUp"
          Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0">
        <Image Source="/Images/Icons/Arrow_u.png"/>
      </Button>
    </Grid>

    <Grid Grid.Column="2" Grid.Row="1" Grid.RowSpan="2" Margin="0,0,0,-10">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="0.15*"/>
      </Grid.RowDefinitions>
      <TextBlock Grid.Row="0"
          FontFamily="Segoe UI" FontSize="28" Text="i miei prodotti" Margin="8,0,0,0"
          VerticalAlignment="Top"/>
      <ListBox Grid.Row="1"
           x:Name="_productsLB"
           ItemsSource="{Binding ProductQuery}"
           ScrollViewer.HorizontalScrollBarVisibility="Disabled"
           ScrollViewer.VerticalScrollBarVisibility="Hidden"
           HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch"
           VerticalContentAlignment="Bottom"
           PreviewMouseLeftButtonDown="_productsLB_PreviewMouseLeftButtonDown"
           PreviewTouchDown="_productsLB_PreviewTouchDown"
           MouseRightButtonUp="_productsLB_MouseRightButtonUp"
           MouseDoubleClick="_productsLB_MouseRightButtonUp"
           BorderThickness="0">
        <ListBox.ItemsPanel>
          <ItemsPanelTemplate>
            <UniformGrid Columns="{Binding Columns}" Rows="{Binding Rows}" IsItemsHost="True"/>
          </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.ItemTemplate>
          <DataTemplate>
            <Border BorderThickness="1" Background="White" BorderBrush="Black" Margin="6,6,6,0"
            Width="Auto" Height="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth}"
            HorizontalAlignment="Stretch">
              <Grid>
                <Image VerticalAlignment="Center" HorizontalAlignment="Center"
                    Margin="0" Source="{Binding ImagePath}" Stretch="Uniform"/>
                <TextBlock Name="DeleteProductTB" VerticalAlignment="Top"
                    HorizontalAlignment="Right"
                    FontFamily="Arial" FontWeight="Bold" FontSize="20" Foreground="Magenta"
                    Text="X"
                    MouseLeftButtonDown="DeleteProductTB_MouseLeftButtonDown"
                    TouchUp="DeleteProductTB_TouchUp"/>
                <TextBlock Name="ZoomProductTB" VerticalAlignment="Bottom"
                    HorizontalAlignment="Right"
                    FontFamily="Arial" FontWeight="Bold" FontSize="24" Foreground="#FF4800AE" Text="+"
                    MouseLeftButtonDown="ZoomProductTB_MouseLeftButtonDown"
                    TouchUp="ZoomProductTB_TouchUp"/>
              </Grid>
            </Border>
          </DataTemplate>
        </ListBox.ItemTemplate>
      </ListBox>

      <Grid Grid.Row="2">
        <Grid.RowDefinitions>
          <RowDefinition Height=".125*"/>
          <RowDefinition Height=".75*"/>
          <RowDefinition Height=".125*"/>
        </Grid.RowDefinitions>        
        <Grid Grid.Row="1">
          <Button Margin="75,0,0,0"
              Height="{Binding RelativeSource={RelativeSource AncestorType=RowDefinition, Mode=FindAncestor}, Path=ActualHeight}"
              VerticalAlignment="Top" HorizontalAlignment="Center"
              Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0"
              Click="scorri_Click" TouchUp="Scorri_TouchUp"
              MaxHeight="75" >
            <Image Source="/Images/Icons/Arrow_r2.png" Stretch="Uniform"/>
          </Button>          
          <Rectangle
              Height="2" VerticalAlignment="Center"
              Width="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualWidth}" Fill="Gray"/>          
          <Button Margin="0,0,75,0"
               Height="{Binding RelativeSource={RelativeSource AncestorType=RowDefinition, Mode=FindAncestor}, Path=ActualHeight}"
               HorizontalAlignment="Center"
               HorizontalContentAlignment="Stretch"
               Name="scorriSX"  VerticalAlignment="Bottom"
               Click="scorriSX_Click" TouchUp="scorriSX_TouchUp"
              Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0"
              MaxHeight="75">
            <Image Source="/Images/Icons/Arrow_l2.png" Stretch="Uniform"/>
          </Button>
        </Grid>
      </Grid>
    </Grid>
    --><!-- Action Buttons--><!--
    <Grid Grid.Column="1" Grid.Row="2" Margin="20,0,20,0">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="0.8*"/>
        <ColumnDefinition Width="Auto"/>        
      </Grid.ColumnDefinitions>
      <Button Grid.Column="0"
              Name="PrintBT" HorizontalAlignment="Left"
              Click="Print_Click" TouchUp="PrintBT_TouchUp"
              Content="Stampa" Template="{StaticResource ResourceKey=ActionButton}"
              Width="{Binding ElementName=ExcelBT, Path=ActualWidth}" MaxHeight="40"
              FontSize="14"/>
      <DockPanel Grid.Column="1" HorizontalAlignment="Center"
          Margin="8,0,8,0"
          Width="{Binding RelativeSource={RelativeSource AncestorType=ColumnDefinition,Mode=FindAncestor},Path=ActualWidth}">
        <DockPanel.Resources>
          <Style TargetType="{x:Type Button}">
            <Setter Property="Margin" Value="4 0 0 0"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="MaxHeight" Value="50"/>
            <Setter Property="MaxWidth" Value="50"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Background" Value="{x:Null}"/>
            <Setter Property="BorderBrush" Value="{x:Null}"/>
            <Setter Property="BorderThickness" Value="0"/>
          </Style>
        </DockPanel.Resources>
        <Button Name="HelpBT" Click="HelpBT_Click" MaxWidth="75">
          <Border BorderBrush="Gray" BorderThickness="3" Background="White">
            <TextBlock FontFamily="Arial" FontWeight="Bold" Text="HELP" FontSize="20"
                Margin="0 10"/>
          </Border>
        </Button>        
        <Button Name="DuplicateBT" Click="DuplicateBT_Click" TouchUp="DuplicateBT_TouchUp">
          <Image Source="/Images/Icons/Duplica.png" Stretch="Fill"/>
        </Button>        
        <Button Name="FlipHorBT" Click="Flip_Click" TouchUp="Flip_TouchUp">
          <Image Source="/Images/Icons/SpecchiaHori.png" Stretch="Fill"/>
        </Button>        
        <Button Name="FlipVertBT" Click="Flip_Click" TouchUp="Flip_TouchUp">
          <Image Source="/Images/Icons/SpecchiaVert.png" Stretch="Fill"/>
        </Button>        
        <Button Name="AlignVert" Click="Align_Click" TouchUp="Align_TouchUp">
          <Image Source="/Images/Icons/AlignVert.png" Stretch="Fill"/>
        </Button>        
        <Button Name="AlignHor" Click="Align_Click" TouchUp="Align_TouchUp">
          <Image Source="/Images/Icons/AlignHor.png" Stretch="Fill"/>
        </Button>
        <Button Name="RotateBT" Click="RotateBT_Click" TouchUp="RotateBT_TouchUp">
          <Image Source="/Images/Icons/ruota.png" Stretch="Fill"/>
        </Button>        
        <Button Name="DeleteBT" Click="DeleteBT_Click" TouchUp="DeleteBT_TouchUp">
          <Image Source="/Images/Icons/delete.png" Stretch="Fill"/>
        </Button>       
        <Button Name="ZoomInBT" Click="Zoom_Click" TouchUp="Zoom_TouchUp">
          <Image Source="/Images/Icons/ZoomIn.png" Stretch="Fill"/>
        </Button>
        <Button Name="ZoomOutBT" Click="Zoom_Click" TouchUp="Zoom_TouchUp">
          <Image Source="/Images/Icons/ZoomOut.png" Stretch="Fill"/>
        </Button>
        <Button Name="ZoomFitBT" Click="Zoom_Click" TouchUp="Zoom_TouchUp">
          <Image Source="/Images/Icons/ZoomFit.png" Stretch="Fill"/>
        </Button>
        <Button Name="NewPageBT" Click="NewPageBT_Click" TouchUp="NewPageBT_TouchUp">
          <Image Source="/Images/Icons/new_page.png" Stretch="Fill"/>
        </Button>
      </DockPanel>
      <Button Grid.Column="2" Name="ExcelBT" HorizontalAlignment="Left"
          Click="ExcelBT_Click" TouchUp="ExcelBT_TouchUp"
          Content="Preventivo" Template="{StaticResource ResourceKey=ActionButton}"
          MaxHeight="40" FontSize="14"/>      
    </Grid>
    <Slider Visibility="Collapsed" Grid.Column="2" Grid.Row="2" VerticalAlignment="Bottom" Height="23" HorizontalAlignment="Right"
        Name="_zoomSilder" Width="100" Minimum="0.25" Maximum="4"
        ValueChanged="_zoomSilder_ValueChanged"/>
  </Grid>
</Window>-->
